{include file="public/header"}
<style type="text/css">
	.in_body{background-color:#E6FDCD;}
	.res_section1 .all_1 .f1 .s1{color:#fff;}
	.res_section1 .all_1 .f2 .s1{color:#fff;}
	.f1 .input1,.f2 .input1{color:#000;background:none}
	::-webkit-input-placeholder {color: #fff;}
	::-moz-placeholder {color: #fff;}
	:-ms-input-placeholder {color: #000;}
	.bg_fixed{position: fixed;
		width: 100%;
		top: 0px;
		left: 0px;
		z-index: -1;
		background: url(__PUBLIC__/home/images/v8_1.png);
		background-size: 100% 100%;}
</style>
<body class="">
<div class="sectionY sectionY_tttt">
	<a href="javascript:history.back();">
		<img src="__PUBLIC__/home/images/v10_a9.png" alt="" class="a1">
	</a>
	<p class="p1" style="color: #fff">
		<span class="ppp_title">重置密码</span>
	</p>
</div>
<div class="kong1"></div>
<div class="bg_fixed_v10_1"></div>
<div class="res_section1">
		<div class="all_1">
			<div class="f2">
				<span class="s1 ">手机号码</span>
				<input type="number" name='phone'  id="phone" class="input1" placeholder="手机号">
<!--				<input type="text" class="input1" placeholder="验证码" name='codes' />-->
				<span class="s2 s3 sxf" id="getVcode">获取验证码</span>
			</div>
			<div class="f1">
				<span class="s1 ">验证码</span>
				<input type="password" name='codes' class="input1" placeholder="请输入短信验证码">
				<!--				<input type="number" name='phone'  id="phone" class="input1" placeholder="手机号">-->
			</div>
			<div class="f1">
				<span class="s1 ">新密码</span>
				<input type="password" name='pwd' class="input1" placeholder="新密码">
			</div>
			<div class="f1">
				<span class="s1 ">确认密码</span>
				<input type="password" name='newpwd' class="input1" placeholder="确认密码">
			</div>


			<div class="sub">
				<input type="submit" value="提交修改">
			</div>
		</div>
</div>
</body>
<script>
    var is_enable=true;
    $(function(){
        /*获取验证码*/
        $(".s3").click(function(){
            var times = 60;
            var phone	= $('#phone').val();
            if(phone==''){
                layer.alert('请输入手机号!',{icon: 2,shade:0.8,title:"错误提示:"});return false;
            }
            /*手机号格式正确，发送验证码并倒计时开始*/
            $.ajax({
                type: 'POST',
                url: "{:url('Paytype/sendsms')}",
                dataType: "html",
                data: "tel=1&phone="+phone,
                success:function(msg){
                    msg= JSON.parse(msg);
                    if(msg.result_code==0){
                        layer.alert(msg.result_info,{icon: 1,shade:0.8,title:"成功提示:"});
                        is_enable = false;
                        $("#getVcode").html(times+"秒后发送");
                        var index = setInterval(function () {
                            if(times == 0){
                                clearInterval(index);
                                is_enable = true;
                                $("#getVcode").html("发送验证码");
                            }else{
                                times--;
                                $("#getVcode").html(times+"秒后发送");
                            }
                        }, 1000);
                    }else {
                        layer.alert(msg.result_info,{icon: 2,shade:0.8,title:"错误提示:"});
                    }
                },
                error:function(){
                    layer.alert('系统繁忙，请稍后再试！',{icon: 2,shade:0.8,title:"错误提示:"});
                }
            });
        });

        /*重置密码*/
        $("input[type=submit]").click(function(){
            var codes	= $('input[name=codes]').val();
            var pwds	= $('input[name=pwd]').val();
            var newpwd	= $('input[name=newpwd]').val();
            var phone	= $('#phone').val();

            if(pwds==''){
                layer.alert('请输入新密码!',{icon: 2,shade:0.8,title:"错误提示:"});return false;
            }
            if(pwds!=newpwd){
                layer.alert('两次输入的密码不一致！',{icon: 2,shade:0.8,title:"错误提示:"});return false;
            }
            if(phone==''){
                layer.alert('请输入手机号!',{icon: 2,shade:0.8,title:"错误提示:"});return false;
            }
            if(codes==''){
                layer.alert('请输入验证码！',{icon: 2,shade:0.8,title:"错误提示:"});return false;
            }
            $.ajax({
                type: 'POST',
                url: "{:url('Index/doforget')}",
                dataType: "html",
                data: "tel=1001&codes="+codes+"&pwds="+pwds+"&phone="+phone,
                success:function(msg){
                    msg= JSON.parse(msg);
                    if(msg.result_code==0){
                        layer.msg('修改成功！',{icon: 1,shade:0.8,time: 2000,end:function(){
                                window.location.href="{:url('Paytype/safecenter')}";
                            }});
                        return false;
                    }else{
                        layer.alert(msg.result_info,{icon: 2,shade:0.8,title:"错误提示:"});
                    }
                },
                error:function(){
                    layer.alert('系统繁忙，请稍后再试！',{icon: 2,shade:0.8,title:"错误提示:"});
                }
            });
        });
    })
</script>
</html>
